import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/login/index'), hidden: true},
  {path: '/404', component: () => import('@/views/404'), hidden: true},

  // 首页
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: {title: '捐赠后台', icon: 'home'}
    }]
  },

  //banner管理
  {
    path: '/wd/banner',
    component: Layout,
    redirect: '/wd/banner',
    name: 'User',
    meta: {title: 'Banner轮播图', icon: 'nested'},
    children: [
      {
        path: 'banner',
        name: 'Banner',
        component: () => import('@/views/wd/banner/banner'),
        meta: {title: 'Banner轮播图', icon: 'nested'}
      }]
  },

  // 用户管理
  {
    path: '/wd/user',
    component: Layout,
    redirect: '/wd/user',
    name: 'User',
    meta: {title: '用户管理', icon: 'user'},
    children: [
      {
        path: 'user',
        name: 'UserList',
        component: () => import('@/views/wd/user/user'),
        meta: {title: '用户列表', icon: 'tree'}
      },
      {
        path: 'feedback',
        name: 'Feedback',
        component: () => import('@/views/wd/user/feedback'),
        meta: {title: '用户反馈', icon: 'form'}
      }
    ]
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  //申请管理
  {
    path: '/wd/apply',
    component: Layout,
    redirect: '/wd/apply',
    name: 'Example',
    meta: {title: '审核管理', icon: 'example'},
    children: [
      {
        path: 'applyAuth',
        name: 'Apply',
        component: () => import('@/views/wd/apply/applyAuth'),
        meta: {title: '贫困认证审核', icon: 'tree'}
      },
      {
        path: 'applyGoods',
        name: 'ApplyGoods',
        component: () => import('@/views/wd/apply/applyGoods'),
        meta: {title: '物品捐赠审核', icon: 'table'}
      }
    ]
  },
  //订单管理
  {
    path: '/wd/order',
    component: Layout,
    redirect: '/wd/order',
    name: 'OrderManage',
    meta: {title: '订单管理', icon: 'order'},
    children: [
      {
        path: 'order',
        name: 'Order',
        component: () => import('@/views/wd/order/order'),
        meta: {title: '订单管理', icon: 'order'}
      }]
  },

  //朋友圈管理
  {
    path: '/wd/pyq',
    component: Layout,
    redirect: '/wd/pyq',
    name: 'PyqManage',
    meta: {title: '圈子管理', icon: 'pyq'},
    children: [
      {
        path: 'pyq',
        name: 'Pyq',
        component: () => import('@/views/wd/pyq/pyq'),
        meta: {title: '圈子管理', icon: 'pyq'}
      }]
  },

  //修改密码
  {
    path: '/wd/admin',
    component: Layout,
    redirect: '/wd/admin',
    name: 'PyqManage',
    meta: {title: '设置', icon: 'set'},
    children: [
      {
        path: 'admin',
        name: 'Admin',
        component: () => import('@/views/wd/admin/admin'),
        meta: {title: '设置', icon: 'set'}
      }]
  },


  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
